package com.android.movieknight;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class Home extends ListActivity{
	
	public void onCreate(Bundle savedInstanceState) {
		 super.onCreate(savedInstanceState);
		  
		 String[] pages = getResources().getStringArray(R.array.pages_array);
		 setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, pages));
		  
		 ListView listView = getListView();
		 
		 listView.setOnItemClickListener(new OnItemClickListener() {
		  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		    
		   Intent myIntent = null;
		    
		   if(((TextView) view).getText().equals("Login Page")){
		    myIntent = new Intent(view.getContext(), LoginActivity.class);
		   }
		   else if(((TextView) view).getText().equals("Movie Collection")){
			myIntent = new Intent(view.getContext(), MovieCollectionActivity.class);
		   }
		   else if(((TextView) view).getText().equals("Friend List")){
			    myIntent = new Intent(view.getContext(), FriendListActivity.class);
		   }
		   
		   startActivity(myIntent);
		  }
		  
		 });
	}
}

	